home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / CHarvestPane.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-15  |  3.8 KB  |  144 lines  |  [TEXT/ALFA]

  1. /*
  2.     Harvest C
  3.     Copyright 1992 Eric W. Sink.  All rights reserved.
  4.     
  5.     This file is part of Harvest C.
  6.     
  7.     Harvest C is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU Generic Public License as published by
  9.     the Free Software Foundation; either version 2, or (at your option)
  10.     any later version.
  11.     
  12.     Harvest C is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.     
  17.     You should have received a copy of the GNU General Public License
  18.     along with Harvest C; see the file COPYING.  If not, write to
  19.     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.     
  21.     Harvest C is not in any way a product of the Free Software Foundation.
  22.     Harvest C is not GNU software.
  23.     Harvest C is not public domain.
  24.  
  25.     This file may have other copyrights which are applicable as well.
  26.  
  27. */
  28.  
  29. /****
  30.  * CHarvestPane.c
  31.  *
  32.  *    Pane methods for a typical application.
  33.  *
  34.  *  Copyright © 1990 Symantec Corporation.  All rights reserved.
  35.  *
  36.  ****/
  37.  
  38. /**
  39.  *
  40.  *  Most applications will want a scrollable window, so this
  41.  *  class is based on the class CPanorama. All the methods here
  42.  *  would still apply to classes based directly on CPane.
  43.  *
  44.  **/
  45.  
  46. #include "CHarvestPane.h"
  47. #include "CSourceFile.h"
  48. #include "CFile.h"
  49. #include "CDataFile.h"
  50. #include "CList.h"
  51. #include "CHarvestDoc.h"
  52.  
  53. extern RgnHandle gUtilRgn;                // a global utility region
  54.  
  55. void CHarvestPane::IHarvestPane(CScrollPane *anEnclosure, CBureaucrat *aSupervisor)
  56. {
  57.         // call CTable's initialization method. Note that we set the
  58.         // size to zero, because we are going to fit it to its enclosure
  59.  
  60.     CTable::ITable( (CView *) anEnclosure, aSupervisor, 0, 0, 0, 0,
  61.                     sizELASTIC, sizELASTIC);
  62.                     
  63.         // Fit it to its enclosing view, which is the CTableScroller
  64.                     
  65.     FitToEnclosure( TRUE, TRUE);
  66.     
  67.         // Specify gray row and column borders for the cells
  68.     
  69.     SetRowBorders( 1, patCopy, gray);
  70.     SetColBorders( 1, patCopy, gray);
  71.     
  72.     SetDefaults(160,20);
  73.  
  74.         // set selection behavior so dragging selects rectangular areas
  75.     
  76.     SetSelectionFlags( selOnlyOne);
  77.         
  78.         
  79. }
  80.  
  81. void CHarvestPane::GetCellText( Cell aCell, short availableWidth,
  82.             StringPtr itsText)
  83. {
  84.     CHarvestDoc *myDoc;
  85.     CSourceFile *aFile;
  86.     myDoc = (CHarvestDoc *) itsSupervisor;
  87.     aFile = (CSourceFile *) (myDoc->itsSourceFiles->NthItem(aCell.v+1));
  88.     aFile->theFile->GetName(itsText);
  89. }
  90.  
  91. /******************************************************************************
  92.  Draw {OVERRIDE}
  93.  
  94.      Normally you don't need to override CTable::Draw - you override
  95.      DrawCell or GetCellText instead. Here we do it in order to fill
  96.      the area outside the cells with a gray pattern.
  97.      
  98. ******************************************************************************/
  99.  
  100. void CHarvestPane::Draw( Rect *area)
  101. {
  102.     LongRect    r;
  103.     Rect        qdRect;
  104.     RgnHandle    tmpRgn;
  105.     
  106.         // Get a region consisting of the area to be drawn
  107.         // it is already in QuickDraw coordinates.
  108.         
  109.     RectRgn( gUtilRgn, area);
  110.     
  111.         // Get the intersection of the bounds and frame rects
  112.         // This corresponds to the cells that are visible.
  113.     
  114.     SectLongRect( &bounds, &frame, &r);
  115.     
  116.         // Since that rect is in Frame coordinates, convert it to
  117.         // a rect in QuickDraw coordinates
  118.         
  119.     FrameToQDR( &r, &qdRect);
  120.     
  121.         // Get a region consisting of the above rect
  122.     
  123.     tmpRgn = NewRgn();
  124.     RectRgn( tmpRgn, &qdRect);
  125.     
  126.         // Subtract the visible cell area from the area to be drawn.
  127.         // The region remaining gives use the area to be drawn outside
  128.         // the bounds.
  129.     
  130.     DiffRgn( gUtilRgn, tmpRgn, tmpRgn);
  131.     
  132.         // If it ain't empty, fill it. Then dispose of the temporary region
  133.     
  134.     if (!EmptyRgn( tmpRgn))
  135.         FillRgn( tmpRgn, gray);
  136.     
  137.     DisposeRgn( tmpRgn);
  138.     
  139.         // inherited::Draw draws the cells
  140.         
  141.     inherited::Draw( area);
  142.     
  143. }
  144.